procedure linkto(ref, contents) return linklabelto(&null, ref, contents) end
procedure linklabel(label, contents) return linklabelto(label, &null, contents) end @ Another support function is used for wrapping tags around text: «*»= procedure sgmlwrap(tag, s) return "<" || tag || ">" || s || "</" || tag || ">" end @ Lucky for us, HTML has few special characters. Unlucky for us, we have to deal with each one seperately. Nothing much to whine about, really. «*»= procedure escapeSpecials (l) static escapes, specials initial escapes := table(); escapes["&"] := "&" escapes["<"] := "<" escapes[">"] := ">" escapes[" ""] := """ specials := '' every specials ++:= key(escapes) s := "" l ? while s ||:= tab(upto(specials)) do s ||:= escapes[move(1)] return s || tab(0) end @ A special function is used to implement noweb's quoting convention within chunk names. «*»= procedure convquotes(s) r := "" s ? # don't call escapeSpecials on s; it destroys internal markup while r ||:= tab(find("[[")) do ="[[" | stop("impossible missing [[") r ||:= "<code>" || tab(find("]]")) r ||:= tab(many(']')-2) ="]]" | stop("impossible missing ]]") r ||:= "</code>" return r || tab(0) end @ «*»= procedure warn_unknown(tag) static warned initial warned := set() if not member(warned, tag) then write(&errout, "Warning: unrecognized escape @", tag, " ", tab(0)) insert(warned, tag) return end @